home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / Pakiet bezpieczenstwa / mini Pentoo LiveCD 2006.1 / mpentoo-2006.1.iso / livecd.squashfs / usr / lib / python2.4 / test / test_macostools.pyo (.txt) < prev    next >
Python Compiled Bytecode  |  2005-10-18  |  3KB  |  110 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.4)
  3.  
  4. import unittest
  5. import macostools
  6. import Carbon.File as Carbon
  7. import MacOS
  8. import os
  9. import sys
  10. from test import test_support
  11. TESTFN2 = test_support.TESTFN + '2'
  12.  
  13. class TestMacostools(unittest.TestCase):
  14.     
  15.     def setUp(self):
  16.         fp = open(test_support.TESTFN, 'w')
  17.         fp.write('hello world\n')
  18.         fp.close()
  19.         rfp = MacOS.openrf(test_support.TESTFN, '*wb')
  20.         rfp.write('goodbye world\n')
  21.         rfp.close()
  22.  
  23.     
  24.     def tearDown(self):
  25.         
  26.         try:
  27.             os.unlink(test_support.TESTFN)
  28.         except:
  29.             pass
  30.  
  31.         
  32.         try:
  33.             os.unlink(TESTFN2)
  34.         except:
  35.             pass
  36.  
  37.  
  38.     
  39.     def compareData(self):
  40.         fp = open(test_support.TESTFN, 'r')
  41.         data1 = fp.read()
  42.         fp.close()
  43.         fp = open(TESTFN2, 'r')
  44.         data2 = fp.read()
  45.         fp.close()
  46.         if data1 != data2:
  47.             return 'Data forks differ'
  48.         
  49.         rfp = MacOS.openrf(test_support.TESTFN, '*rb')
  50.         data1 = rfp.read(1000)
  51.         rfp.close()
  52.         rfp = MacOS.openrf(TESTFN2, '*rb')
  53.         data2 = rfp.read(1000)
  54.         rfp.close()
  55.         if data1 != data2:
  56.             return 'Resource forks differ'
  57.         
  58.         return ''
  59.  
  60.     
  61.     def test_touched(self):
  62.         macostools.touched(test_support.TESTFN)
  63.  
  64.     
  65.     def test_copy(self):
  66.         
  67.         try:
  68.             os.unlink(TESTFN2)
  69.         except:
  70.             pass
  71.  
  72.         macostools.copy(test_support.TESTFN, TESTFN2)
  73.         self.assertEqual(self.compareData(), '')
  74.  
  75.     
  76.     def test_mkalias(self):
  77.         
  78.         try:
  79.             os.unlink(TESTFN2)
  80.         except:
  81.             pass
  82.  
  83.         macostools.mkalias(test_support.TESTFN, TESTFN2)
  84.         (fss, _, _) = Carbon.File.ResolveAliasFile(TESTFN2, 0)
  85.         self.assertEqual(fss.as_pathname(), os.path.realpath(test_support.TESTFN))
  86.  
  87.     
  88.     def test_mkalias_relative(self):
  89.         if not os.path.exists(sys.prefix):
  90.             return None
  91.         
  92.         
  93.         try:
  94.             os.unlink(TESTFN2)
  95.         except:
  96.             pass
  97.  
  98.         macostools.mkalias(test_support.TESTFN, TESTFN2, sys.prefix)
  99.         (fss, _, _) = Carbon.File.ResolveAliasFile(TESTFN2, 0)
  100.         self.assertEqual(fss.as_pathname(), os.path.realpath(test_support.TESTFN))
  101.  
  102.  
  103.  
  104. def test_main():
  105.     test_support.run_unittest(TestMacostools)
  106.  
  107. if __name__ == '__main__':
  108.     test_main()
  109.  
  110.